package com.neu.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neu.entity.Role;
import com.neu.mapper.RoleMapper;
import com.neu.service.RoleService;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
    @Override
    public Role getRoleIdsById(String roleId) {
        return baseMapper.selectById(roleId);
    }

    @Override
    public Set<Role> getRoleIdsById(Set<String> roleIds) {
        if (roleIds == null || roleIds.isEmpty()) {
            return Collections.emptySet();
        }
        Set<Role> roles = new HashSet<>();
        roleIds.forEach(roleId -> {
            Role role = baseMapper.selectById(roleId);
            if (role != null) {
                roles.add(role);
            }
        });
        return  roles;
    }
}
